package com.itheima.runnable;

import java.util.ArrayList;
import java.util.concurrent.*;

public class Test {
    //掌握线程池执行Runnable任务
    public static void main(String[] args) {
        ExecutorService pool = new ThreadPoolExecutor(
                2,
                5,
                3,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(3),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy()
        );
        //执行任务
        pool.execute(()->{
            System.out.println(Thread.currentThread().getName()+"正在执行");
            try {
                Thread.sleep(1000);
            }catch (InterruptedException e){
              throw new RuntimeException(e);
            }
        });

        }
    }

